package org.ekstrabilet.user.permissions;

import org.ekstrabiltet.user.Action;

public class UserPermissions {
	private static final String[] ADMIN_PERMISSIONS= {Action.ADD_PRICES, Action.ADD_STADIUM, Action.MANAGE_USERS, Action.ADD_GAME, Action.BROWSE_CART, Action.ADD_TICKET};
	private static final String[] TECH_PERMISSIONS= {Action.ADD_PRICES, Action.ADD_STADIUM, Action.ADD_GAME, Action.BROWSE_CART, Action.ADD_TICKET};
	private static final String[] USER_PERMISSIONS= {Action.BROWSE_CART, Action.ADD_TICKET};
	private static final String ADMIN= "Administration";
	private static final String TECH= "Technical service";
	private static final String USER= "View";
	
	public static boolean checkPermissions(String userType, String action){
		
		if(userType.equals(ADMIN)){
			for(String act : ADMIN_PERMISSIONS){
				if(act.equals(action))
					return true;
			}
				
		}
		
		if(userType.equals(TECH)){
			for(String act : TECH_PERMISSIONS){
				if(act.equals(action))
					return true;
			}
				
		}
		
		if(userType.equals(USER)){
			for(String act : USER_PERMISSIONS){
				if(act.equals(action))
					return true;
			}
				
		}
		return false;	
	}
}
